package edu.etu.sob.resource;

import java.io.IOException;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;

import edu.etu.sob.model.Todo;
import edu.etu.sob.model.impl.OntClassDesc;
import edu.etu.sob.service.OntologyManager;

@Path("/classes/{uri}")
public class OntClassResource {
	
	private OntologyManager ontologyManager;
	private String url = "http://www.co-ode.org/ontologies/pizza/pizza.owl";

	public OntClassResource() {
		ontologyManager = new OntologyManager();
	}

	public Todo getTodos(@PathParam("uri") String uri) {
		Todo todo = new Todo();
		todo.setDescription(url+"#"+uri);
		todo.setSummary("sssss");
		return todo;
	}
	
	@GET
	@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	public OntClassDesc getClassDesc(@PathParam("uri") String uri) throws IOException {
		OntModel model = ontologyManager.createOntologyModel(url);
		
		OntClass ontClass = model.getOntClass(url+"#"+uri);
		OntClassDesc classDesc = new OntClassDesc(ontClass);
		classDesc.addSuperClasses(ontClass.listSuperClasses(true));
		
		return classDesc;
	}
}
